//
//  FinishedOrderViewController.m
//  car
//
//  Created by chenxu on 4/16/15.
//  Copyright (c) 2015 chenxu. All rights reserved.
//

#import "FinishedOrderViewController.h"
#import "price_cell.h"
#import "Input_LeftRightLabel_Cell.h"
#import "Input_LeftImage_Cell.h"
#import "LeftImage_RightButton_Cell.h"
#import "carinfo_cell.h"
#import "InputOnlyTextPlainCell.h"
#import "LeftImg_cell.h"
#import "Input_LeftImage_RightImage_Cell.h"

#import "Insurance.h"

#define kCellIdentifier_price @"price_cell"
#define kCellIdentifier_contact @"contact_cell"
#define kCellIdentifier_carinfo @"carinfo_cell"
#define kCellIdentifier_normal @"normal_cell"
#define kCellIdentifier_inputplain @"input_cell"
#define kCellIdentifier_button @"button_cell"
#define kCellIdentifier_yanzhenma @"yanzhenma_cell"
#define kCellIdentifier_checkbox @"checkbox_cell"
@interface FinishedOrderViewController ()

@end

@implementation FinishedOrderViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
    [_myTableView registerClass:[carinfo_cell class] forCellReuseIdentifier:kCellIdentifier_carinfo];
    [_myTableView registerClass:[price_cell class] forCellReuseIdentifier:kCellIdentifier_price];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    // Return the number of sections.
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
    if(section == 0){
        return 7;
    }
    else{
        return [_myOrder getXianzhong].count;
    }
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 0) {//车辆信息
        
        carinfo_cell* cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_carinfo forIndexPath:indexPath];
        NSString *title = @"11";
        NSString *value = @"";
        NSInteger row = indexPath.row;
        if (row == 0){
            title = @"车牌号";
            value = _myOrder.Carid;
        }
        if (row == 1) {
            title = @"车品牌";
            value = _myOrder.Carpinpai;
        }
        if (row == 2){
            title = @"保险到期";
            value = _myOrder.Carbaoxiandaoqi;
        }
        if (row == 3){
            title = @"购车日期";
            value = _myOrder.Carbuydate;
        }
        if (row == 4){
            title = @"发动机号";
            value = _myOrder.Carfadongjiid;
        }
        if (row == 5){
            title = @"车价格";
            value = _myOrder.Carprice;
        }
        if (row == 6){
            title = @"车型号";
            value = _myOrder.Carxinghao;
        }
        [cell setLeft:title right:value];
        return cell;
    }
    if (indexPath.section == 1) {//保险信息
        NSArray* xianzhong = [_myOrder getXianzhong];
        price_cell* cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_price forIndexPath:indexPath];
        Insurance* ins = [xianzhong objectAtIndex:indexPath.row];
         NSString *title = ins.xianming;
         NSString *value = ins.price;
        [cell setLeft:title right:value];
        return cell;
    }
    return  nil;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}



@end
